<?php
namespace app\growthArchives\controller;
use app\common\Base;
use think\Db;

class TeacherArchives extends Base {
	
	public function index() {
		return $this->fetch();
	}

	public function pageQuery() {
		$result = Db::table("教师常规参数")->select();
		return selectResult($result);
	}

	public function addUpdate() {
		try {
			$param = request()->param();
			if(array_key_exists("ID", $param)) {
				update('教师常规参数', $param);
			}else {
				insert('教师常规参数', $param);
			}
			return '000';
		} catch (Exception $e) {
			echo $e->getMessage();
		}
		return "999";
	} 

	public function del() {
		$delIds = input("delIds");
		try {
			Db::name('教师常规参数')->where('ID','in',explode(",", $delIds))->delete();
			return "000";
		} catch (Exception $e) {
			echo $e->getMessage();
		}
		return "999";
	}

	public function departList() {
		$result = Db::table("教师常规参数")
				  ->field("部门名称 value")
				  ->select();
		$list = [];
		foreach ($result as $key => $obj) {
			$list[$key] = array("text"=>$obj["value"], "value"=>$obj["value"]);
		}
		return $list;
	}

	public function commentTypeList() {
		$where["部门名称"] = request()->param("depart");
		$result = Db::table("教师常规参数")
				  ->field("常规类别 value")
				  ->where($where)
				  ->find();
		$array = explode(",", $result["value"]);
		$list = [];
		foreach ($array as $key => $value) {
			$list[$key] = array("text"=>$value, "value"=>$value);
		}
		return $list;
	}

}
